Skip to content

Conversation

@didoo
Copy link
Contributor

@didoo didoo commented Sep 25, 2025

Note

This PR is quite large, we may consider splitting it up in multiple PRs

📌 Summary

This PR contains multiple pieces of the "theming" puzzle:

  • the implementation of an hdsTheming service and a (temporary) HdsThemeSwitcher component
  • the implementation of a shwTheming service and set of showcase controls to switch theming (and theming options) plus the CSS file linked in the application
  • the implementation of a "Foundations > Theming" showcase page, plus a frameless demo page (with theme switcher) to demonstrate how theming applies to different HDS components and a mock application in general

This is based on top of #3259

🛠️ Detailed description

The first commits are a direct porting of previous showcase theming explorations (squashed):

After the initial cherry picking of code, there's been a lot of back and forth / refactorings, with different attempts in reaching an implementation that could (hopefully) withstand how different teams may want to adopt theming in their codebases. For this reason, the bulk of the work has been around finding the right "location" for the different pieces of logic, the different concerns: what goes into the HDS theming service vs the SHW theming service; how theming preferences are expressed in the UI and controlled by the user; how consumers decisions are reflected and stored and passed over between HDS/SHW services and components; how a user would use the theming controls (including a showcase user/developer/designer) and how a consumer would allow that user to interact with the application.

It's impossible to describe in detail all the code changes and implementations introduced in this PR, you have to look at diff in code, the showcase application, the "how to review" and "how to test" sections below, and try to get a general picture of what went into this PR.

👉 👉 👉 Preview: theming page

🔎 How to review

This is a quite large PR (we may consider splitting it). I would suggest to look at a piece of code/logic (eg. HDS theming service), see how this interacts with the rest of the code (in HDS and/or in the showcase), and in parallel I would try to see in the showcase application how this logic is reflected in the UI, and try to interact with it to see what happens.

The "logical" order in which I would look at things is this:

  • start to look at the hdsTheming service and HdsThemeSwitcher component under packages/components
  • move on to the shwTheming service under showCase and see how it's an extension of the hdsTheming (something we may undo, if we remove the globalOnSetTheme callback, see below)
  • look at the ShwThemeSwitcher controls (component and sub-components) and see how they're using internally both the hdsTheming and shwTheming services, how the "current" theming options are reflected in the services and in the controls values/states, what happens when a control value is updated/applied, etc
  • see how the showcase has now a small set of themed CSS variables for its colors, so it can respond to the theming changes in the controls/switchers (and how the "static" color values have been replaced across the existing pages/components)
  • look at the foundations/theming showcase page, and its sections
    • the first one is a showcase of the HdsThemSwitcher component
    • the second section is used to test how "contextual theming" (applying a theme at "local" level via a class or data attribute) works, even when nested
    • the third section shows how the HDS "themed" components work (at the moment we have not decided yet how they will be handled in a themed application, but for now at least we have them collected in a single place)
    • the last section is a frameless demo of a mock application with a collection of the most common HDS components
  • see how some of the "Mock" components and pages had to be updated, to accomodate for changes to the AppSideNav (where we've added a theme switcher) and to add even more "mock" UI elements to test with theming
  • look at the temporary files in the public/assets/styles/@hashicorp/ folder, in particular the CSS selectors, and see if they make sense

🛠️ How to test

Launch the showcase application locally, then visit the "Foundations > Theming" page. Here play with the controls in the top right of the page, and see how changing them impacts the page:

  • try to change the theming (you have multiple option groups and options, corresponding to the different way the consumers may want to adopt/use the HDS theming
  • try to change theming via the HDS theme switcher and see how this is reflected in the SHW controls
  • open the advanced options settings and see how setting/applying them see
  • look at the local storage in the devtools, and see how the values get updated when the different options are chose/set
  • look at the different sections of the theming page and see how theming and theming options apply (or don't) to them
  • try to apply different themes to other showcase page (in this case, since the theming tokens are only partially defined, don't expect proper theming switch, the component will look broken)

If you want to double check how the tokens and their values are applied depending on the chosen theme/options, you can update the colors in the temporary/testing CSS files under the public/assets/styles/@hashicorp/ folder (see the CSS variables under the added these to test theming in the showcase comment)

💬 To discuss/decide

🗒️ TODOs

📸 Screenshots

Screen.Recording.2025-10-21.at.15.31.39.mov

🔗 External links

Jira tickets:


👀 Component checklist

  • Percy was checked for any visual regression
  • A changelog entry was added via Changesets if needed (see templates here)
    • changelogs will be added in the main feature branch

💬 Please consider using conventional comments when reviewing this PR.

📋 PCI review checklist
  • If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
  • If applicable, I've worked with GRC to document the impact of any changes to security controls.
    Examples of changes to controls include access controls, encryption, logging, etc.
  • If applicable, I've worked with GRC to ensure compliance due to a significant change to the in-scope PCI environment.
    Examples include changes to operating systems, ports, protocols, services, cryptography-related components, PII processing code, etc.

@vercel
Copy link

vercel bot commented Sep 25, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
hds-showcase Ready Ready Preview Oct 29, 2025 2:28pm
hds-website Ready Ready Preview Oct 29, 2025 2:28pm

@didoo didoo changed the title [WIP] [Project Solaris / Phase 1 / Showcase] Add support for theming and theme-switching to the showcase [WIP] [Project Solis / Phase 1 / Showcase] Add support for theming and theme-switching to the showcase Sep 25, 2025
@didoo didoo changed the title [WIP] [Project Solis / Phase 1 / Showcase] Add support for theming and theme-switching to the showcase [WIP] [Project Solar/ Phase 1 / Showcase] Add support for theming and theme-switching to the showcase Sep 25, 2025
@didoo didoo changed the title [WIP] [Project Solar/ Phase 1 / Showcase] Add support for theming and theme-switching to the showcase [WIP] [Project Solar / Phase 1 / Showcase] Add support for theming and theme-switching to the showcase Sep 25, 2025
@didoo didoo force-pushed the project-solar/phase-1/HDS-5242_showcase/add-themes-support branch from b73dbf9 to a4f41dd Compare September 30, 2025 14:11
@didoo didoo force-pushed the project-solar/phase-1/HDS-5242_showcase/add-themes-support branch from a4f41dd to cc61972 Compare September 30, 2025 14:20
@didoo didoo force-pushed the project-solar/phase-1-main-feature-branch branch from 519a6a6 to 3863dfa Compare September 30, 2025 14:50
@didoo didoo force-pushed the project-solar/phase-1/HDS-5242_showcase/add-themes-support branch from cc61972 to 59418c1 Compare September 30, 2025 16:16
@didoo didoo force-pushed the project-solar/phase-1/HDS-5242_showcase/add-themes-support branch from 59418c1 to 2f20cdc Compare September 30, 2025 17:23
@didoo didoo force-pushed the project-solar/phase-1/HDS-5242_showcase/add-themes-support branch from 2f20cdc to 92910be Compare September 30, 2025 17:23
@didoo didoo force-pushed the project-solar/phase-1/HDS-5242_showcase/add-themes-support branch from 92910be to a1ff2f5 Compare September 30, 2025 20:23
didoo and others added 21 commits October 29, 2025 10:19
Assertion Failed: You attempted to update _isInitialized on <HdsThemingService:ember77>, but it had already been used previously in the same computation. Attempting to update a value after using it in a computation can cause logical errors, infinite revalidation bugs, and performance issues, and is not supported.

_isInitialized was first used:

While rendering:
{{outlet}} for -top-level
-top-level
{{outlet}} for application
Application

sq
while we understand how to do nesting of theming
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants